import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;


public class TimerTaskTest {

	private static TimerTask task = new TimerTask() {   
	    public void run() {   
	    	System.out.println(Thread.currentThread().getName() + " time:" + System.currentTimeMillis());
	    }   
	}; 
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		long millis = System.currentTimeMillis();
		Calendar c = Calendar.getInstance();
		c.setTimeInMillis(millis);
//		c.set(Calendar.HOUR_OF_DAY, 1);
//		c.set(Calendar.MINUTE, 0);
//		c.set(Calendar.SECOND, 0);
		c.add(Calendar.MINUTE, 1);
		System.out.println("calenda:" + c.getTime());
		
		Timer timer = new Timer();
//		timer.scheduleAtFixedRate(task, new Date(millis + 30 * 1000), 24 * 60 * 60 *1000);
//		timer.scheduleAtFixedRate(task, new Date(millis + 30 * 1000), 60 *1000);
		timer.scheduleAtFixedRate(task, c.getTime(), 60 *1000);
		while (true) {
			try {
				Thread.sleep(60*1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println(Thread.currentThread().getName() + " time:" + System.currentTimeMillis());
		}
	}
}
